<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="${staticServer}/inc/style/main.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/page.css" />
<link rel="stylesheet" href="${staticServer}/css/struct_info.css" />
<script src="${staticServer}/inc/js/jquery.js"></script>
<script src="${staticServer}/inc/js/pageset.js"></script>
<script src="${staticServer}/inc/js/submitter.js"></script>
<script src="${staticServer}/inc/js/infopad.js?2.2"></script>
	
<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<script src="${staticServer}/inc/js/datepicker.js"></script>

<style>
#SWFUpload_0{
	margin-top: 70px;
    margin-left: -30px;
}
</style>
<script>
var contextPath='${contextPath}';
var _contextPath = '${staticServer}';

$(function(){
	$("#c_username").val("<#if travel??>${travel.c_username}</#if>");
	$("#type").val("<#if travel??>${travel.type}</#if>");
	
	$("#nickname").keyup(function(){
		var nickname = $("#nickname").val();
		
		$.post("${contextPath}/index/getUserByNickname2.json", {
			"nickname" : nickname
		}, function(ms) {
			var username = ms.user.username;
			$("#c_username").val(username);
		});
	});
});

var addTravel = function(){
	var id = $("#id").val();
	var c_username = $("#c_username").val();
	var type = $("#type").val();
	var address = $("#address").val();
	var startTime = $("#startTime").val();
	
	var times = $("#times").val();
	var msg = $("#msg").val();
	var moneys1 = $("#moneys1").val();
	var moneys2 = $("#moneys2").val();
	var beizhu = $("#beizhu").val();
	
	if(c_username==""){
		infopad.err("请选择出差人员!");
		return;
	}
	if(type==""){
		infopad.err("请选择出差工具!");
		return;
	}
	
	if(address==""){
		infopad.err("请填写目的地城市!");
		return;
	}
	if(startTime==""){
		infopad.err("请选择出差日期!");
		return;
	}
	if(times==""){
		infopad.err("请填写出差预计天数!");
		return;
	}
	if(msg==""){
		infopad.err("请填写出差事由!");
		return;
	}
	if(moneys1==""){
		infopad.err("请填写车次航班价格!");
		return;
	}
	
	$.post("${contextPath}/index/add_travel.json", {
			"id":id,
			"c_username":c_username,
			"type":type,
			"address":address,
			"startTime":startTime,
			"times":times,
			"msg":msg,
			"moneys1":moneys1,
			"moneys2":moneys2,
			"beizhu":beizhu
		}, function(ms) {
		    var msg = ms.msg;
		    if(msg!=null && msg=="1"){
				infopad.msg("操作成功！");
				window.location.href="${contextPath}/index/travelList.htm";
		    }else{
		    	infopad.err("操作失败，请联系管理员！");
		    }
			
	});
};

</script>
</head>
<input type="hidden" id="id" value="<#if travel??>${travel.id}</#if>">
<body>
	<div id="home_link">
		<ul>
			<li></li>
			<li>&gt;</li>
			<li>组织架构</li>
			<li>&gt;</li>
			<li class="current">title</li>
		</ul>
	</div>

	<div id="container">
		<div id="title">添加出差记录</div>
		<table id="infotable">
			
			<tr>
				<th>出差人员:</th>
				<td>
					<select id="c_username">
					<#if list??>
						<option value="">请选择目标出差人</option>
						<#list list as list>
							<option value="${list.username}">${list.nickname}(${list.departments}-${list.job})</option>
						</#list>
					</#if>
					</select>
					<input type="text" id="nickname" size="20" value="" placeholder="请输入姓名快速搜索">
				</td>
			</tr>
			
			<tr>
				<th>出差工具:</th>
				<td>
					<select id="type">
						<option value="">请选择</option>
						<option value="1">飞机</option>
						<option value="2">火车</option>
						<option value="3">汽车</option>
					</select>
				</td>
			</tr>
			
			<tr>
				<th>目的地城市:</th>
				<td>
					<input type="text" id="address" size="30" value="<#if travel??>${travel.address}</#if>">
				</td>
			</tr>
			
			<tr>
				<th>出差日期:</th>
				<td>
					<input type="text" id="startTime" placeholder="开始日期" value="<#if travel??>${travel.startTime}</#if>" rel="DATE::Y-m-d" value="" size="14" maxlength="15" readonly="readonly" class="DatePicker_Icon">
				</td>
			</tr>
			
			<tr>
				<th>出差预计天数:</th>
				<td>
					<input type="text" id="times" size="10" value="<#if travel??>${travel.times}</#if>" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-9.]/g,'')">天
				</td>
			</tr>
			
			<tr>
				<th>出差事由:</th>
				<td>
					<input type="text" id="msg" size="40" value="<#if travel??>${travel.msg}</#if>">
				</td>
			</tr>
			
			<tr>
				<th>车次航班价格:</th>
				<td>
					<input type="text" id="moneys1" size="10" value="<#if travel??>${travel.moneys1}</#if>" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-9.]/g,'')">元
				</td>
			</tr>
			
			<tr>
				<th>住宿价格:</th>
				<td>
					<input type="text" id="moneys2" size="10" value="<#if travel??>${travel.moneys2}</#if>" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-9.]/g,'')">元
				</td>
			</tr>
			
			<tr>
				<th>备注:</th>
				<td>
					<input type="text" id="beizhu" size="60" value="<#if travel??>${travel.beizhu}</#if>">
				</td>
			</tr>
			
		</table>
		<div id="controlbar">
		<#if webutil.getCookieUser().username=="wangjianv" || webutil.getCookieUser().username=="system"  || webutil.getCookieUser().username=="liulan">
			<input type="button" class="submit" onclick="addTravel()" value="  保  存  " />
		</#if>
		</div>
	</div>
	
</body>
</html>